package com.ficus.road.maintain.core.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @Author hao.zhou1
 * @Since 2021/4/7 下午8:36
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class GpsLocation implements Serializable {
    private static final long serialVersionUID = 3113738766452758674L;
    /**
     * 经度
     */
    private double longitude;
    /**
     * 纬度
     */
    private double latitude;

    public static double calDistance(GpsLocation location1, GpsLocation location2) {
        double jl_jd = 102834.74258026089786013677476285;
        double jl_wd = 111712.69150641055729984301412873;
        double b = Math.abs((location1.getLongitude() - location2.getLongitude()) * jl_jd);
        double a = Math.abs((location1.getLatitude() - location2.getLatitude()) * jl_wd);
        return Math.sqrt((a * a + b * b));
    }
}
